
<template>
    <my-form v-model="form" @submit="submit" @cancle="cancle" ref="form" labelWidth='100px'  >
        <el-row>
             <el-col :span="12">
                <el-form-item label="税号：">
                   {{fpDetail.creditcode || '-'}}
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="账号：" >
                   {{fpDetail.jbzhzh || '-'}}
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="名称：" >
                   {{fpDetail.dwname || '-'}}
                </el-form-item>
            </el-col>
             <el-col :span="12">
                <el-form-item label="电话：" >
                   {{fpDetail.phone || '-'}}
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="开户行：" >
                   {{fpDetail.khbank || '-'}}
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="开票金额：" >
                   {{fpDetail.invoiceAmount || '-'}} 元
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="地址：" >
                   {{fpDetail.address || '-'}}
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
             <el-col :span="24">
                <el-form-item label="发票编号：" prop="number" :rules="newRule('发票编号', 'required')">
                    <el-input v-model="form.number"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="发票文件：" prop="file">
                    <upload-new @setfile="getfile"></upload-new>
                </el-form-item>
            </el-col>
        </el-row>
    </my-form>
</template>

<script>




export default {

     props: {
        rowguid: {
            type: String,
            default: ''
        },
        requesturl:{
            type: String,
            default:'/bhtong/settmg/settItemChild/invoice'
        },
        needinvoice:{
            type: String,
            default: '',
        }
    },
    components:{},
    data: function(){
        return{
            form:{
                file:'',
                number:''
            },
            fpDetail:{},
        }
    }, 
    computed:{
        
    },
    watch:{
    },

    methods: {
        submit:function(){  
            if(this.needinvoice == 1){
                if(this.form.file){
                    this.$post(this.requesturl,{
                        rowguid:this.rowguid,
                        invoiceFile:this.form.file,
                        invoiceNo:this.form.number,
                    },function(data,res){
                        if(res.code == 'v'){
                            this.cancle();
                            ShowMsg('提交成功','success');
                        }else{
                            ShowMsg(res.msg,'warning');
                        }
                    })
                }else{
                    ShowMsg('请上传发票文件','warning');
                }
            }else{
                this.$post(this.requesturl,{
                    rowguid:this.rowguid,
                    invoiceFile:this.form.file,
                    invoiceNo:this.form.number,
                },function(data,res){
                    if(res.code == 'v'){
                        this.cancle();
                        ShowMsg('提交成功','success');
                    }else{
                        ShowMsg(res.msg,'warning');
                    }
                })
            }
        },
        cancle:function(){
            this.$emit('close');
        },
        getfile:function(val){
            this.form.file = val;
        },
        getDetail:function(){
            this.$get(`${this.getGetters('settUrl')}/settItemChild/invoiceInfo`,{
                rowguid:this.rowguid,
            },function(data){
                this.fpDetail = data;
            })
        },
        //获取惠采购详情
        getHcgDetail:function(){
            this.$get(`${this.getGetters('settUrl')}/hcgSettItem/invoiceInfo`,{
                rowguid:this.rowguid,
            },function(data){
                this.fpDetail = data;
            })
        },

    },
    mounted() {
        if(this.requesturl == '/bhtong/settmg/hcgSettItem/invoice'){
            this.getHcgDetail();
        }else{
            this.getDetail();
        }
    }
}
</script>

<style scoped lang="scss">




</style>
